import execjs
import js
import requests


d = {
    "libraryId": 33,
    "sectionId": 208,
    "filterConfigIds": [
        271,
        269,
        270,
        1404,
        889,
        305,
        272,
        266,
        1825,
        267,
        268,
        1162
    ],
    "queryParam": {
        "start": 0,
        "limit": 20,
        "searchFieldIds": None,
        "is_oversea": [
            "1",
            "2",
            "3",
            "4"
        ],
        "query_field_ids": None
    }
}

res = requests.post('https://vip.xiniudata.com/api/vip/web/login/logout',json = {
    "v": -20180620
})

with open('js/犀牛数据.js','r')as f:
    js_str = f.read()
    js_code = execjs.compile(js_str)
    r = js_code.call("get_payload_sign",d)
    r["v"]=1

    res = requests.post("https://vip.xiniudata.com/api/vip/library/v3/init",json=r,cookies={
        'satoken':'1a6c1eb6-e486-4540-a47c-65df28b03d06; Max-Age=31536000;'
    })
    data = res.json()['d']
    js_code = execjs.compile(js_str)
    data = js_code.call("get_data",data)
    print(data)


